package cn.icanci.ladybird.controller;

import cn.icanci.ladybird.common.result.JsonData;
import cn.icanci.ladybird.pojo.dto.UserBuyerTicketDTO;
import cn.icanci.ladybird.pojo.entity.UserInfo;
import cn.icanci.ladybird.service.UserInfoService;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: zxp
 * @date: Created in 2020/10/7 0007 下午 16:09
 * @classAction: 会员列表分页与数据显示
 */

@SuppressWarnings("all")
@Controller
@Slf4j
@RequestMapping("/api/v1/pri/admin")
public class AdminUserListController {

    @Autowired
    private UserInfoService userInfoService;

//    @ResponseBody
//    @RequestMapping("/userlist")
//    public JsonData getUserIndex(Model model, Integer pageNum, Integer pageSize){
//        PageInfo<UserInfo> userInfoPageInfo= userInfoService.queryAllByNotObject(pageNum, pageSize);
//        return JsonData.builderSuccess(userInfoPageInfo);
//    }

    /**
     * 跳转到 user-list 票列表
     *
     * @param model 数据处理对象
     * @return 返回视图地址
     */
    @RequestMapping("/users-list")
    public String adminTicketList(Model model, Integer pageNum, Integer pageSize) {
        // 页面参数，然后在Service进行分页
        PageInfo<UserInfo> userInfoPageInfo= userInfoService.queryAllByNotObject(pageNum, pageSize);
        JsonData jsonData = JsonData.builderSuccess(userInfoPageInfo);
        model.addAttribute("jsonData", jsonData);
        return "admin/user-list";
    }

}
